

#if !defined mainframeheadfile 
#define mainframeheadfile 

void mainframe(); 
void playermessage(); 
void mainhint(int n); 
int buttonmotion(int x,int y,int b); 
void clearbutton(); 
void initmainframe(int x,int y); 
int openfile(char*fn); 
void autoplay(); 

void mainframe() 
{ 
int x=320,tx,y=240,ty,b=0,tb,exit=0; 
char fn[10]={0}; 
initmainframe(x,y); 
while(!exit) 
{ 
readm(&tx,&ty,&tb); 
if(tx!=x||ty!=y) 
{ 
putmimage(x,y); 
x=tx,y=ty,b=tb; 
buttonmotion(x,y,b); 
loadmimage(x,y); 
arrowhead(x,y); 
} 
else if(tb!=b) 
{ 
int wherego; 
b=tb; 
putmimage(x,y); 
wherego=buttonmotion(x,y,b); 
arrowhead(x,y); 
if(b==0) 
{ 
switch(wherego) 
{ 
case 0:if(!openfile(fn)) 
messagebox(240,200,400,250,"file not load!");break; 
case 1:edit(fn);break; 
case 2:autoplay();break; 
case 3:handplay();break; 
case 4:exit=1;break; 
default:break; 
} 
if(wherego!=-1)initmainframe(x,y); 
} 
} 
} 
} 
void initmainframe(int x,int y) 
{ 
setfillstyle(1,color[9]); 
bar(0,0,640,480); 
menupad(10,10,629,469,3); 
winrect(20,40,619,429); 
playermessage(); 
setcolor(color[15]); 
outtextxy(18,18,"Sound Player"); 
setcolor(color[0]); 
outtextxy(78,80,"open"); 
outtextxy(158,80,"edit"); 
outtextxy(238,80,"auto"); 
outtextxy(318,80,"hand"); 
outtextxy(398,80,"exit"); 
winrect(60,65,130,105); 
winrect(140,65,210,105); 
winrect(220,65,290,105); 
winrect(300,65,370,105); 
winrect(380,65,450,105); 
mainhint(0); 
initm(10,10,629,469); 
loadmimage(x,y); 
arrowhead(x,y); 
} 
void playermessage()
{
winrect(100,170,539,320); 
setcolor(color[8]); 
settextjustify(1,2); 
outtextxy(320,200,"2004.1.18 ->1.21"); 
outtextxy(320,230,"Projected By"); 
outtextxy(320,260,"NBU 024"); 
outtextxy(320,290,"Lynn"); 
setcolor(color[15]); 
outtextxy(319,199,"2004.1.18 ->1.21"); 
outtextxy(319,229,"Projected By"); 
outtextxy(319,259,"NBU 024"); 
outtextxy(319,289,"Lynn"); 
settextjustify(0,2); 
} 
void mainhint(int n)
{ 
char*s[6]={"","Goto open *.opn file...", 
"Goto edit *.opn file...", 
"Goto auto play current notes...", 
"Goto handing play...", 
"Go back to windows..."}; 
if(hintstyle==n)return; 
n=abs(n)%6; 
hintstyle=n; 
setfillstyle(1,7); 
bar(30,440,300,448); 
outtextxy(30,440,s[n]); 
}
int buttonmotion(int x,int y,int b)
{
int butt=-1; 
setcolor(color[7]); 
if(y>70&&y<100) 
if(b) 
{ 
if(x>65&&x<125)
{ 
butt=0; 
if(butt!=bt||bdn!=b) 
buttondn(65,70,125,100); 
} 
else if(x>145&&x<205) 
{ 
butt=1; 
if(butt!=bt||bdn!=b) 
buttondn(145,70,205,100); 
} 
else if(x>225&&x<285) 
{ 
butt=2; 
if(butt!=bt||bdn!=b) 
buttondn(225,70,285,100); 
} 
else if(x>305&&x<365) 
{ 
butt=3; 
if(butt!=bt||bdn!=b) 
buttondn(305,70,365,100); 
} 
else if(x>385&&x<445) 
{ 
butt=4; 
if(butt!=bt||bdn!=b) 
buttondn(385,70,445,100); 
} 
else clearbutton(); 
} 
else 
{ 
if(x>65&&x<125) 
{ 
butt=0; 
if(butt!=bt||bdn!=b) 
buttonup(65,70,125,100); 
} 
else if(x>145&&x<205) 
{ 
butt=1; 
if(butt!=bt||bdn!=b) 
buttonup(145,70,205,100); 
} 
else if(x>225&&x<285) 
{ 
butt=2; 
if(butt!=bt||bdn!=b) 
buttonup(225,70,285,100); 
} 
else if(x>305&&x<365) 
{ 
butt=3; 
if(butt!=bt||bdn!=b) 
buttonup(305,70,365,100); 
} 
else if(x>385&&x<445) 
{ 
butt=4; 
if(butt!=bt||bdn!=b) 
buttonup(385,70,445,100); 
} 
else clearbutton(); 
} 
else clearbutton(); 
mainhint(butt+1); 
bt=butt; 
bdn=b; 
return butt; 
} 
void clearbutton() 
{ 
clbutton(65,70,125,100); 
clbutton(145,70,205,100); 
clbutton(225,70,285,100); 
clbutton(305,70,365,100); 
clbutton(385,70,445,100); 
} 
int openfile(char*fn) 
{ 
int x0=260,y0=200,x1=450,y1=260,success=0; 
menupad(x0,y0,x1,y1,3); 
setcolor(15); 
outtextxy(x0+8,y0+8,"please input file name"); 
outtextxy(x0+125,y0+36,".opn"); 
setcolor(color[8]); 
outtextxy(x0+124,y0+35,".opn"); 
setfillstyle(1,color[2]); 
bar(x0+20,y0+30,x0+120,y0+46); 
buttondn(x0+20,y0+30,x0+120,y0+46); 
inputfn(fn,1); 
success=loadnotes(fn); 
return success; 
} 
void autoplay() 
{ 
putpad("Automatism Player"); 
bookplay(1); 
getch(); 
} 

#endif
/*end of mframe.h*/ 